/* 封装分类业务逻辑代码 */
import { getCategroysAPI } from '@/apis/category';
import { ref, onMounted, watch } from 'vue';
import { useRouter } from 'vue-router';
export function useCategory() {
    const router = useRouter()
    const categoryData = ref({})
    const getCategroys = async () => {
        const { data: res } = await getCategroysAPI(router.currentRoute.value.params.id)
        categoryData.value = res.result
    }

    onMounted(() => getCategroys())
    watch(() => router.currentRoute.value.params.id,
        () => getCategroys()
    )
    return {
        categoryData
    }
}